package com.design.yjx.command.common;

/**
 * @author yuanjianxin
 * @date 2017/8/21 15:31
 */
public class FanOffCommand2 implements Command {
    private Fan fan;
    private Fan.Speed prevSpeed;

    public FanOffCommand2(Fan fan) {
        this.fan = fan;
    }

    @Override
    public void execute() {
        prevSpeed = fan.getSpeed();
        fan.setSpeed(Fan.Speed.OFF);
    }

    @Override
    public void undo() {
        fan.setSpeed(prevSpeed);
    }
}
